package vn.nt.healthcare.server.ws.controller;

import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import vn.nt.healthcare.server.ws.model.Reports;
import vn.nt.healthcare.server.ws.service.ReportsService;

@Controller
public class ReportsController {

	
	@Autowired
	private ReportsService reportService;

	@RequestMapping(value = "/detailreport", method = RequestMethod.GET)
	@ResponseBody
	public Reports findReportById(
			HttpServletRequest request,
			@RequestParam(value = "companyId", required = true) String companyId,
			@RequestParam(value = "id", required = true) int id) {
		return reportService.findReportById(companyId, id);
	}

	@RequestMapping(value = "/lastestreport", method = RequestMethod.GET)
	@ResponseBody
	public Reports findLastestReport(
			HttpServletRequest request,
			@RequestParam(value = "companyId", required = true) String companyId,
			@RequestParam(value = "customerId", required = true) int customerId) {
		return reportService.findLastestReports(companyId, customerId);
	}

	@RequestMapping(value = "/listreports", method = RequestMethod.GET)
	@ResponseBody
	public List<Reports> findReportsByStaffInTime(
			HttpServletRequest request,
			@RequestParam(value = "companyId", required = true) String companyId,
			@RequestParam(value = "staffId", required = true) int staffId,
			@RequestParam(value = "fromDate", required = true) Date fromDate,
			@RequestParam(value = "toDate", required = true) Date toDate) {
		return reportService.findReportsByStaffInTime(companyId, staffId,
				fromDate, toDate);
	}

	@RequestMapping(value = "/listreportsbybaby", method = RequestMethod.GET)
	@ResponseBody
	public List<Reports> findReportsByStaffIdAge(
			HttpServletRequest request,
			@RequestParam(value = "companyId", required = true) String companyId,
			@RequestParam(value = "staffId", required = true) int staffId,
			@RequestParam(value = "fromAge", required = true) int fromAge,
			@RequestParam(value = "toAge", required = true) int toAge) {
		return reportService.findReportsByStaffIdAge(companyId, staffId,
				fromAge, toAge);
	}

	@RequestMapping(value = "/listreportsbydoctor", method = RequestMethod.GET)
	@ResponseBody
	public List<Reports> findReportsByStaff(
			HttpServletRequest request,
			@RequestParam(value = "companyId", required = true) String companyId,
			@RequestParam(value = "staffId", required = true) int staffId) {
		return reportService.findReportsByStaff(companyId, staffId);
	}
}
